//------------------------------------------------------------------------------
// Copyright (c) 2008 www.dnaide.com
// Licensed under the MIT (MIT-LICENSE.txt)
//------------------------------------------------------------------------------
using System;
using System.Text;
using System.Globalization;

namespace DNAide.Core
{
	public static partial class StringAide
	{
		/// <summary>
		/// Generates latin text
		/// </summary>
		/// <param name="latinTextType">LatinTextType</param>
		/// <param name="latinTextPartType">LatinTextPartType</param>
		/// <param name="amount">Amount</param>
		/// <returns>String</returns>
		public static String GenerateLatin(LatinTextType latinTextType, LatinTextPartType latinTextPartType, Int32 amount)
		{
			string latinText;
			StringBuilder tempText;
			int i = 0;

			if (amount < 0) amount = 1;
			switch (latinTextType)
			{
				case LatinTextType.EpsumFactorial:
					latinText = Resources.StringAide.EpsumFactorial;
					break;
				case LatinTextType.LiEuropan:
					latinText = Resources.StringAide.LiEuropan;
					break;
				case LatinTextType.MaQuande:
					latinText = Resources.StringAide.MaQuande;
					break;
				default:
					latinText = Resources.StringAide.LoremIpsum;
					break;
			}

			switch (latinTextPartType)
			{
				case LatinTextPartType.Characters:
					latinText = Left(latinText, amount);
					break;
				case LatinTextPartType.Words:
					string[] words = latinText.Split(" ".ToCharArray(), StringSplitOptions.None);
					if (words.Length > amount)
					{
						tempText = new StringBuilder();
						for (i = 0; i < amount; i++)
						{
							tempText.AppendFormat("{0} ", words[i]);
						}
						latinText = tempText.ToString();
					}
					break;
				case LatinTextPartType.Paragraphs:
					tempText = new StringBuilder();
					for (i = 0; i < amount; i++)
					{
						tempText.AppendFormat("{0}\r\n", latinText);
					}
					latinText = tempText.ToString();
					break;
				default:
					tempText = new StringBuilder();
					for (i = 0; i < amount; i++)
					{
						tempText.AppendFormat("<p>{0}</p>", latinText);
					}
					latinText = tempText.ToString();
					break;
			}

			return latinText;
		}

	}
}
